<template>
	<view class="content" :style="{background:'#F7F7F7;'}">
		<view class="inc-exp-list" :style="{background:'#FFFFFF;'}">
			<block v-for="(item, index) in list" :key="index">
				<view class="item-center" :style="{'border-bottom':'2rpx solid #E8E8E8;'}">
					<view class="item" style="margin-bottom: 20rpx;" :style="{color:'#111111;'}">
						<text>{{item.type_name}}</text>
						<text v-if="item.op == 1">+{{item.amount}}</text>
						<text v-if="item.op == 0">+{{item.amount}}</text>
					</view>
					<view class="item" :style="{color:'#AEAEAE;'}">
						<text>{{item.create_time}}</text>
						<text>当前积分：{{item.before_amount}}</text>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
	var util = require('@/js/util.js')
	export default {
		data() {
			return {
				page:1,
				size:30,
				list:[]
			};
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			this.page++
			this.getList()
		},
		methods:{
			getList(){
				let _self = this
				uni.request({
					url: util.getUrl("member/game_coin"),
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation':uni.getStorageSync("token")
					},
					data:{
						page:_self.page,
						size:_self.size,
					},
					method: 'POST',
					success: res => {
						if(res.data.code == 1){
							if(_self.page == 1){
								if(res.data.data.length<=0){
									uni.showToast({
										title:'暂无更多信息！',
										icon:'none'
									})
								}else{
									_self.list = res.data.data.list
								}
							}else if(res.data.data.length <=0){
								this.page --
								uni.showToast({
									title:'暂无更多信息！',
									icon:'none'
								})
							}else{
								for(let key in res.data.data){
									_self.list.push(res.data.data[key])
								}
							}
						}else{
							uni.showToast({
								title:res.data.msg,
								icon:'none'
							})
						}
					},
				});
			},
		}
	}
</script>

<style lang="scss">
	.inc-exp-list{
		width: 690upx;
		display: flex;
		align-items: center;
		flex-direction: column;
		border-radius: 20upx;
		box-sizing: border-box;
		padding: 0 30upx;
		.item-center{
			display: flex;
			align-items: center;
			flex-direction: column;
			width: 100%;
			box-sizing: border-box;
			padding: 30upx 0;
			.item{
				display: flex;
				align-items: center;
				justify-content: space-between;
				width: 100%;
			}
		}
	}
	.content{
		display: flex;
		align-items: center;
		flex-direction: column;
		width: 750upx;
		min-height: 100vh;
		padding: 30upx;
		box-sizing: border-box;
	}
</style>
